{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 2019.03.28 No NumPy"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import metadsl.nonumpy.compat as np\n",
    "import metadsl.expressions as exp\n",
    "\n",
    "import dataclasses"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "NDArray(__value__=Call(function=<function array_call at 0x7f95dc3bbbf8>, args=(ArrayLike(__value__=[1, 2, 3]), Optional(__value__=None, inner_type=InstanceType(type=<class 'metadsl.nonumpy.compat.DType'>, args=())), Optional(__value__=None, inner_type=InstanceType(type=<class 'metadsl.nonumpy.compat.Boolean'>, args=())), Optional(__value__=None, inner_type=InstanceType(type=<class 'metadsl.nonumpy.compat.ArrayOrder'>, args=())), Optional(__value__=None, inner_type=InstanceType(type=<class 'metadsl.nonumpy.compat.Boolean'>, args=())), Optional(__value__=10, inner_type=InstanceType(type=<class 'metadsl.nonumpy.compat.Natural'>, args=())))))"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "n = np.array([1, 2, 3], ndmin=10)\n",
    "n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'__value__': {'function': <function metadsl.nonumpy.compat.array_call(object: metadsl.nonumpy.compat.ArrayLike, dtype: metadsl.nonumpy.compat.Optional[metadsl.nonumpy.compat.DType], copy: metadsl.nonumpy.compat.Optional[metadsl.nonumpy.compat.Boolean], order: metadsl.nonumpy.compat.Optional[metadsl.nonumpy.compat.ArrayOrder], subok: metadsl.nonumpy.compat.Optional[metadsl.nonumpy.compat.Boolean], ndmin: metadsl.nonumpy.compat.Optional[metadsl.nonumpy.compat.Natural]) -> metadsl.nonumpy.compat.NDArray>,\n",
       "  'args': ({'__value__': [1, 2, 3]},\n",
       "   {'__value__': None,\n",
       "    'inner_type': {'type': metadsl.nonumpy.compat.DType, 'args': ()}},\n",
       "   {'__value__': None,\n",
       "    'inner_type': {'type': metadsl.nonumpy.compat.Boolean, 'args': ()}},\n",
       "   {'__value__': None,\n",
       "    'inner_type': {'type': metadsl.nonumpy.compat.ArrayOrder, 'args': ()}},\n",
       "   {'__value__': None,\n",
       "    'inner_type': {'type': metadsl.nonumpy.compat.Boolean, 'args': ()}},\n",
       "   {'__value__': 10,\n",
       "    'inner_type': {'type': metadsl.nonumpy.compat.Natural, 'args': ()}})}}"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dataclasses.asdict(n)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'type': {'type': metadsl.nonumpy.compat.NDArray, 'args': ()},\n",
       " 'value': {'function': <function metadsl.nonumpy.compat.array_call(object: metadsl.nonumpy.compat.ArrayLike, dtype: metadsl.nonumpy.compat.Optional[metadsl.nonumpy.compat.DType], copy: metadsl.nonumpy.compat.Optional[metadsl.nonumpy.compat.Boolean], order: metadsl.nonumpy.compat.Optional[metadsl.nonumpy.compat.ArrayOrder], subok: metadsl.nonumpy.compat.Optional[metadsl.nonumpy.compat.Boolean], ndmin: metadsl.nonumpy.compat.Optional[metadsl.nonumpy.compat.Natural]) -> metadsl.nonumpy.compat.NDArray>,\n",
       "  'args': ({'type': {'type': metadsl.nonumpy.compat.ArrayLike, 'args': ()},\n",
       "    'value': [1, 2, 3]},\n",
       "   {'type': {'type': metadsl.nonumpy.compat.Optional,\n",
       "     'args': ({'type': metadsl.nonumpy.compat.DType, 'args': ()},)},\n",
       "    'value': None},\n",
       "   {'type': {'type': metadsl.nonumpy.compat.Optional,\n",
       "     'args': ({'type': metadsl.nonumpy.compat.Boolean, 'args': ()},)},\n",
       "    'value': None},\n",
       "   {'type': {'type': metadsl.nonumpy.compat.Optional,\n",
       "     'args': ({'type': metadsl.nonumpy.compat.ArrayOrder, 'args': ()},)},\n",
       "    'value': None},\n",
       "   {'type': {'type': metadsl.nonumpy.compat.Optional,\n",
       "     'args': ({'type': metadsl.nonumpy.compat.Boolean, 'args': ()},)},\n",
       "    'value': None},\n",
       "   {'type': {'type': metadsl.nonumpy.compat.Optional,\n",
       "     'args': ({'type': metadsl.nonumpy.compat.Natural, 'args': ()},)},\n",
       "    'value': 10})}}"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dataclasses.asdict(exp.Expression.from_instance(n))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "NDArray(__value__=Call(function=<function arange_call at 0x7f95dc3bbea0>, args=(Optional(__value__=None, inner_type=InstanceType(type=<class 'metadsl.nonumpy.compat.Number'>, args=())), Number(__value__=10), Optional(__value__=None, inner_type=InstanceType(type=<class 'metadsl.nonumpy.compat.Number'>, args=())), Optional(__value__=None, inner_type=InstanceType(type=<class 'metadsl.nonumpy.compat.DType'>, args=())))))"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.arange(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
